package com.hgw.Demo11_VisitorPattern.Exercises26_7_4;

/**
 * Data time:2021/12/21 21:10
 * StudentID:2019112118
 * Author:hgw
 * Description: 苹果，充当具体元素类
 */
public class Apple implements Commodity{
    private String name;
    private double weight;
    private int price;

    public Apple(String name, double weight, int price) {
        this.name = name;
        this.weight = weight;
        this.price = price;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getWeight() {
        return weight;
    }

    public void setWeight(double weight) {
        this.weight = weight;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    @Override
    public void accept(People people) {
        people.visit(this); // 调用访问者的访问方法
    }
}
